package com.org.Bibliotech;

/**
 * Created by Joshua on 6/7/2014.
 */

import java.util.ArrayList;


public class Library {
    private ArrayList<Book> availableBooks;
    private ArrayList<Book> checkedOutBooks;

    private ArrayList<Movie> availableMovies;
    private ArrayList<Movie> checkedOutMovies;

    public Library(ArrayList<Book> availableBooks){


        this.availableBooks = availableBooks;
        this.checkedOutBooks = new ArrayList<Book>();
    }

    public Library(ArrayList<Book> availableBooks, ArrayList<Movie> availableMovies){

        this.availableBooks = availableBooks;
        this.checkedOutBooks = new ArrayList<Book>();
        this.availableMovies = availableMovies;
        this.checkedOutMovies = new ArrayList<Movie>();
    }



    public ArrayList<Movie> getAvailableMovies(){
        return availableMovies;
    }
    public ArrayList<Book> getAvailableBooks(){
        return availableBooks;
    }

    public int getNumberOfBooks(){
        return availableBooks.size();
    }

    public ArrayList<Book> getCheckedOutBooks(){
        return checkedOutBooks;
    }

    public ArrayList<Movie> getCheckedOutMovies(){return checkedOutMovies; }


    public  boolean checkoutBook(Book book){

        if(!availableBooks.contains(book))
            return false;

        availableBooks.remove(book);
        checkedOutBooks.add(book);

        return true;

    }


    public boolean checkoutMovie(Movie movie){

        if(!availableMovies.contains(movie))
            return false;

        availableMovies.remove(movie);
        checkedOutMovies.add(movie);

        return true;
    }
    public boolean returnBook(Book book){

        if(!checkedOutBooks.contains(book))
            return false;


        checkedOutBooks.remove(book);
        availableBooks.add(book);


        return true;
    }







}
